import {coreApi, parseToChart} from '../apis/core-util'
import TimeStore from 'lib/stores/time-store'
import _ from 'underscore'
import moment from 'moment'

export default class LineChart {
  constructor(props, container) {
    this.container = container;
    this.$state = {
      lineChart: {
        loading: true
      }
    };

    this.$state.lineChartApi = coreApi({
      size: 30,
      sm: 1,
      offset: 0,
      limit: 200,
      classify: null,
      urlName: 'activitytracesimilar',
      viewKey: 'framerate_listLine'
    }, TimeStore.getValue);
  }

  $load() {
    return this.$state.lineChartApi.fetch().done((json, params) => {
      this.$state.lineChart = {
        data: parseToChart(json, params)
      };
      this.container.emit();
    });
  }
}
